//
// mixins 方法
//---------------------------------------

// 大小设置
//----------------------------
.size(@width, @height) {
	width: @width;
	height: @height;
}
.square(@size) {
	.size(@size; @size);
}

// 小图标data
//----------------------------
.uri(@a){
	background-image: data-uri('@pimg/@{a}');
}

//三角形
//----------------------
.add-sjx(@a:@border-color-d5){
	width: 0;
	height: 0;
	color: @a;
	vertical-align: middle;
}
// 向上
.add-up(@a:@border-color-d5,@b:@u*10,@c:@b){.add-sjx(@a);
	border-right: @c solid transparent;
	border-left: @c solid transparent;
	border-bottom:@b solid;
}
// 向右
.add-left(@a:@border-color-d5,@b:@u*10,@c:@b){.add-sjx(@a);
	border-top: @c solid transparent;
	border-bottom: @c solid transparent;
	border-right:@b solid;
}
// 向下
.add-down(@a:@border-color-d5,@b:@u*10,@c:@b){.add-sjx(@a);
	border-right: @c solid transparent;
	border-left: @c solid transparent;
	border-top:@b solid;
}
// 向左
.add-right(@a:@border-color-d5,@b:@u*10,@c:@b){.add-sjx(@a);
	border-top: @c solid transparent;
	border-bottom: @c solid transparent;
	border-left:@b solid;
}

//	css3过度
//	-------------------------
.trs(@a:0.5s){
	-webkit-transition: @a;
	-moz-transition: @a;
	-ms-transition: @a;
	-o-transition: @a;
	transition: @a;
}

//	css3变形
//	-------------------------
.trf(@a:scale(1.1)){
	-webkit-transform: @a;
	-moz-transform: @a;
	-ms-transform: @a;
	-o-transform: @a;
	transform: @a;
}

// 箭头
// -------------
.arrow-m(@c;@w;@b){
	.square(@w);
	border-bottom: @c solid @b;
	border-left: @c solid @b;
}
// 向上
.arrow-up(@c:@font-color-6;@w:@u*20;@b:@u*2){
	.arrow-m(@c,@w,@b);
	.trf(rotate(135deg));
}
// 向右
.arrow-right(@c:@font-color-6;@w:@u*20;@b:@u*2){
	.arrow-m(@c,@w,@b);
	.trf(rotate(-135deg));
}
// 向下
.arrow-down(@c:@font-color-6;@w:@u*20;@b:@u*2){
	.arrow-m(@c,@w,@b);
	.trf(rotate(-45deg));
}
// 向左
.arrow-left(@c:@font-color-6;@w:@u*20;@b:@u*2){
	.arrow-m(@c,@w,@b);
	.trf(rotate(45deg));
}

// 盒模型 box
//-------------------------
.box() {
	display: -webkit-box;
    display: -moz-box;
	display: box;
}
// 转换成盒模型并垂直居中
.box-p(@a:center){
	.box;
	-webkit-box-align:@a;
	-moz-box-align:@a;
	box-align:@a;
}
// 水平居中
.box-pack(@a:center){
	-webkit-box-pack:@a;
	-moz-box-pack:@a;
	box-pack:@a;
}
//
.box-f(@a:1){
	-webkit-box-flex: @a;
	-moz-box-flex: @a;
	box-flex: @a;
}

.box-sizing(@a: border-box) {
	-webkit-box-sizing: @a;
	-moz-box-sizing: @a;
	box-sizing: @a;
}

// 内阴影
//-------------------
.box-si(@a:1px;@b:#fff){
	box-shadow: inset 0 @a 0 @b,
				inset 0 -@a 0 @b,
				inset @a 0 0 @b,
				inset -@a 0 0 @b;
}
// 单行超出部分省略号显示
//-------------
.slh(){
	text-overflow: ellipsis;
	white-space: nowrap;
	overflow: hidden;
}
// 多行超出部分省略号显示
//-------------
.slh2(){
	overflow : hidden;
	text-overflow: ellipsis;
	display: -webkit-box;
	-webkit-line-clamp: 2;
	-webkit-box-orient: vertical;
}
// 页面跳转箭头
.changego(@cola: #999){
	display: inline-block;
	content: '';
	height: 0.24rem;
	width: 0.24rem;
	border-left: @cola solid 0.04rem;
	border-bottom: @cola solid 0.04rem;
	transform: rotate(-135deg);
}
// 去除默认样式(多用于表单元素)
//--------------------------------
.not-ae(@a:none){
	-webkit-appearance:@a;
	-moz-appearance:@a;
	appearance:@a;
}
// 清除浮动
.clearfix(){
	&:after{
		clear:both; content:""; display:block; height:0; overflow:hidden;
	}
}
// 字体图标
.iconfont(){
	font-family:"iconfont" !important;
	font-size:@font-size-base;
	font-style:normal;
	-webkit-font-smoothing: antialiased;
	-webkit-text-stroke-width: 0.2px;
	-moz-osx-font-smoothing: grayscale;
}
.it(@a){
	&::after{
		.iconfont();
		content: '@{a}';
	}
}

.ib(@a){
	&::before{
		.iconfont();
		content: '@{a}';
	}
}
//上下边框
.border(top, @width:1px, @color:@border-color-d5) {
	border-top: @width solid @color;
}
.border(bottom, @width:1px, @color:@border-color-d5) {
	border-bottom: @width solid @color;
}


//  css3渐变
//	-------------------------
// 线性渐变
// 例子:bac-l(~'to top,',~'#ccc,#000,#ccc,#000');
.bac-l(@s:'to lest,';@rest...){
	background: -webkit-linear-gradient(@s @rest);
	background: -o-linear-gradient(@s @rest);
	background: linear-gradient(@s @rest);
}

// 线性渐变
.linear-gradient(@a: #fff, @b: #333, @c: 0deg) {
	background-color: @a;
	background-image: -webkit-gradient(linear, center top, center bottom, from(@a), to(@b));
	background-image: -webkit-linear-gradient(@c, @a, @b);
	background-image: -moz-linear-gradient(@c, @a, @b);
	background-image: -ms-linear-gradient(@c, @a, @b);
	background-image: -o-linear-gradient(@c, @a, @b);
	background-image: linear-gradient(@c, @a, @b);
	//filter: progid:DXImageTransform.Microsoft.gradient(startColorstr=@a, endColorstr=@b, grandientType=1);
}

// 动画
//------------
.ani(@a:none){
	-webkit-animation:@a;
	-moz-animation:@a;
	animation: @a;
}

//
// Clockhand
// -----------------------------------------------------------------------------
//
// ### Usage:
// Helpers for writing properties in clockhand manner.

.clockhand(@values, @prefix: ~"", @suffix: ~"", @collapse: false) {
	@l: length(@values);
	@pre: ~`'@{prefix}' ? '@{prefix}-' : ''`;
	@suf: ~`'@{suffix}' ? '-@{suffix}' : ''`;

	.map(1) {
		@top: extract(@values, 1);
		@right: @top;
		@bottom: @top;
		@left: @top;
	}
	.map(2) {
		@top: extract(@values, 1);
		@right: extract(@values, 2);
		@bottom: @top;
		@left: @right;
	}
	.map(3) {
		@top: extract(@values, 1);
		@right: extract(@values, 2);
		@bottom: extract(@values, 3);
		@left: @right;
	}
	.map(4) {
		@top: extract(@values, 1);
		@right: extract(@values, 2);
		@bottom: extract(@values, 3);
		@left: extract(@values, 4);
	}
	.map(@l);

	.reduce() when (@collapse) and not (@top = _) and not (@right = _)
	and not (@bottom = _) and not (@left = _) {
		.output() {
			@shorthand: @top;
		}
		.output() when not (@right = @top) {
			@shorthand: @top @right;
		}
		.output() when not (@bottom = @top) {
			@shorthand: @top @right @bottom;
		}
		.output() when not (@left = @right) {
			@shorthand: @top @right @bottom @left;
		}
		.output();
			@{prefix}@{suf}: @shorthand;
	}
	.reduce() when (default()) {
		.output() when not (@top = _) {
				@{pre}top@{suf}: @top;
		}
		.output() when not (@right = _) {
				@{pre}right@{suf}: @right;
		}
		.output() when not (@bottom = _) {
				@{pre}bottom@{suf}: @bottom;
		}
		.output() when not (@left = _) {
				@{pre}left@{suf}: @left;
		}
		.output();
	}

	.reduce();
}

.absolute(...) {
	position: absolute;
	.clockhand(@arguments);
}

.fixed(...) {
	position: fixed;
	.clockhand(@arguments);
}

.relative(...) {
	position: relative;
	.clockhand(@arguments);
}

.padding(...) {
	.clockhand(@arguments, padding, ~"", true);
}

.margin(...) {
	.clockhand(@arguments, margin, ~"", true);
}

.border-color(...) {
	.clockhand(@arguments, border, color, true);
}

.border-style(...) {
	.clockhand(@arguments, border, style, true);
}

.border-width(...) {
	.clockhand(@arguments, border, width, true);
}


//
// .ellipsis
//
// Known issue:
// 指定参数（行数）的功能只支持WebKit。

.ellipsis(...) {
	overflow: hidden;
}
.ellipsis() {
	text-overflow: ellipsis;
	-o-text-overflow: ellipsis;
	white-space: nowrap;
}
.ellipsis(@line-number) {
	display: -webkit-box;
	-webkit-line-clamp: @line-number;
	-webkit-box-orient: vertical;
}

//
// force-wrap
//
// 阻止长字符串（例如url或无意义连续英文字符）打破布局
.force-wrap() {
	white-space: pre;           // CSS 2.0
	white-space: pre-wrap;      // CSS 2.1
	white-space: pre-line;      // CSS 3.0
	white-space: -pre-wrap;     // Opera 4-6
	white-space: -o-pre-wrap;   // Opera 7
	white-space: -moz-pre-wrap; // Mozilla
	white-space: -hp-pre-wrap;  // HP Printers
	word-wrap: break-word;      // IE 5+
}

.scrollable(){
	overflow: auto;
	-webkit-overflow-scrolling: touch;
}

.flexbox() {
	display: -webkit-box;
	display: -ms-flexbox;
	display: -webkit-flex;
	display: flex;
}

.flex-wrap(@fw) when (@fw = nowrap) {
	-webkit-box-lines: single;
	-moz-box-lines: single;
	-webkit-flex-wrap: nowrap;
	-ms-flex-wrap: none;
	-ms-flex-wrap: nowrap;
	flex-wrap: nowrap;
}
.flex-wrap(@fw) when (@fw = wrap) {
	-webkit-box-lines: multiple;
	-moz-box-lines: multiple;
	-webkit-flex-wrap: wrap;
	-ms-flex-wrap: wrap;
	flex-wrap: wrap;
}
.flex-wrap(@fw) when not (@fw = wrap) and not (@fw = nowrap) {
	-webkit-flex-wrap: @fw;
	-ms-flex-wrap: @fw;
	flex-wrap: @fw;
}
.flex-shrink(@fs) {
	-webkit-flex-shrink: @fs;
	-ms-flex: 0 @fs auto;
	flex-shrink: @fs;
}
.justify-content(@jc) when (@jc = flex-start) {
	-webkit-box-pack: start;
	-ms-flex-pack: start;
	-webkit-justify-content: flex-start;
	justify-content: flex-start;
}
.justify-content(@jc) when (@jc = flex-end) {
	-webkit-box-pack: end;
	-ms-flex-pack: end;
	-webkit-justify-content: flex-end;
	justify-content: flex-end;
}
.justify-content(@jc) when (@jc = space-between) {
	-webkit-box-pack: justify;
	-ms-flex-pack: justify;
	-webkit-justify-content: space-between;
	justify-content: space-between;
}
.justify-content(@jc) when not (@jc = flex-start) and not (@jc = flex-end) and not (@jc = space-between) {
	-webkit-box-pack: @jc;
	-ms-flex-pack: @jc;
	-webkit-justify-content: @jc;
	justify-content: @jc;
}
.align-items(@ai) when (@ai = flex-start) {
	-webkit-box-align: start;
	-ms-flex-align: start;
	-webkit-align-items: flex-start;
	align-items: flex-start;
}
.align-items(@ai) when (@ai = flex-end) {
	-webkit-box-align: end;
	-ms-flex-align: end;
	-webkit-align-items: flex-end;
	align-items: flex-end;
}
.align-items(@ai) when not (@ai = flex-start) and not (@ai = flex-end) {
	-webkit-box-align: @ai;
	-ms-flex-align: @ai;
	-webkit-align-items: @ai;
	align-items: @ai;
}
.align-content(@ai) {
	-ms-flex-line-pack: @ai;
	-webkit-align-content: @ai;
	align-content: @ai;
}
.align-self(@as) {
	-ms-flex-item-align: @as;
	-webkit-align-self: @as;
	align-self: @as;
}

// clearfix via http://h5bp.com/q
.clearfix() {
	zoom: 1;
	&:before,
	&:after {
		content: " ";
		display: table;
	}
	&:after {
		clear: both;
		visibility: hidden;
		font-size: 0;
		height: 0;
	}
}



.hairline(@position, @color) when (@position = top) {
	&:before {
		content: '';
		position: absolute;
		left: 0;
		top: 0;
		bottom: auto;
		right: auto;
		height: 1px;
		width: 100%;
		background-color: @color;
		display: block;
		z-index: 15;
		transform-origin: 50% 0%;
		@media only screen and (-webkit-min-device-pixel-ratio: 2) {
			transform: scaleY(0.5);
		}
		@media only screen and (-webkit-min-device-pixel-ratio: 3) {
			transform: scaleY(0.33);
		}
	}
}
.hairline(@position, @color) when (@position = left) {
	&:before {
		content: '';
		position: absolute;
		left: 0;
		top: 0;
		bottom: auto;
		right: auto;
		width: 1px;
		height: 100%;
		background-color: @color;
		display: block;
		z-index: 15;
		transform-origin: 0% 50%;
		@media only screen and (-webkit-min-device-pixel-ratio: 2) {
			transform: scaleY(0.5);
		}
		@media only screen and (-webkit-min-device-pixel-ratio: 3) {
			transform: scaleY(0.33);
		}
	}
}
.hairline(@position, @color) when (@position = bottom) {
	&:after {
		content: '';
		position: absolute;
		left: 0;
		bottom: 0;
		right: auto;
		top: auto;
		height: 1px;
		width: 100%;
		background-color: @color;
		display: block;
		z-index: 15;
		transform-origin: 50% 100%;
		@media only screen and (-webkit-min-device-pixel-ratio: 2) {
			transform: scaleY(0.5);
		}
		@media only screen and (-webkit-min-device-pixel-ratio: 3) {
			transform: scaleY(0.33);
		}
	}
}
.hairline(@position, @color) when (@position = right) {
	&:after {
		content: '';
		position: absolute;
		right: 0;
		top: 0;
		left: auto;
		bottom: auto;
		width: 1px;
		height: 100%;
		background-color: @color;
		display: block;
		z-index: 15;
		transform-origin: 100% 50%;
		@media only screen and (-webkit-min-device-pixel-ratio: 2) {
			transform: scaleY(0.5);
		}
		@media only screen and (-webkit-min-device-pixel-ratio: 3) {
			transform: scaleY(0.33);
		}
	}
}
// For right and bottom
.hairline-remove(@position) when not (@position = left) and not (@position = top) {
	&:after {
		display: none;
	}
}
// For left and top
.hairline-remove(@position) when not (@position = right) and not (@position = bottom) {
	&:before {
		display: none;
	}
}
// For right and bottom
.hairline-color(@position, @color) when not (@position = left) and not (@position = top) {
	&:after {
		background-color: @color;
	}
}
// For left and top
.hairline-color(@position, @color) when not (@position = right) and not (@position = bottom) {
	&:before {
		background-color: @color;
	}
}

// Encoded SVG Background
.encoded-svg-background(@svg) {
	@url: `encodeURIComponent(@{svg})`;
	background-image: url("data:image/svg+xml;charset=utf-8,@{url}");
}

// "Unstyle" lists, `.no-bullet()` for `<li>`s and `.no-bullets()` for `<ul>` & `<ol>`
// [deprecated]

.no-bullet() {
	list-style-image: none;
	list-style-type: none;
	margin-left: 0;
}

.no-bullets() {
	list-style: none;
	li {
		.no-bullet();
	}
}

.inline-block() {
	display: inline-block;
	*display: inline;
	*zoom: 1;
}


